import axios from '@/http/axios'
export default{
    namespaced:true,
    state:{
        categoryData:[],
        categoryName:[]
    },
    getters:{},
    mutations:{
        setCategoryData(state,data){
            state.categoryData=data
        },
        setCategoryName(state,name){
            state.categoryName=name
        },
    },
    actions:{
        async toLoadCategoryName(context,params){
            let res = await axios.get('/category/findAll');
            context.commit('setCategoryName',res.data.data)
        },
        async toDeleteCategorys(context,params){
            return await axios.get('/category/deleteById?id='+params)
        },
        async toSaveCategorys(context,params){
            let res = await axios.post('/category/saveOrUpdate',params)
        },
        async toLoadCategorys(context,params){
            let res = await axios.post('/category/query',params)
            context.commit('setCategoryData',res.data.data)
        }
    }
}